package com.css.modules.lawRepo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.css.common.utils.PageUtils;
import com.css.common.utils.Query;
import com.css.modules.lawRepo.dao.LawRepoLegalCategoryDao;
import com.css.modules.lawRepo.entity.LawRepoLegalCategoryEntity;
import com.css.modules.lawRepo.service.LawRepoLegalCategoryService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;


@Service
public class LawRepoLegalCategoryServiceImpl extends ServiceImpl<LawRepoLegalCategoryDao, LawRepoLegalCategoryEntity> implements LawRepoLegalCategoryService {
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<LawRepoLegalCategoryEntity> page = this.page(
                new Query<LawRepoLegalCategoryEntity>().getPage(params),
                new QueryWrapper<LawRepoLegalCategoryEntity>()
        );
        return new PageUtils(page);
    }

    @Override
    public LawRepoLegalCategoryEntity findByKeywords(String keywords) {
        LawRepoLegalCategoryEntity legalCategoryEntity= this.baseMapper.findByKeywords(keywords);
        return legalCategoryEntity;
    }

    @Override
    public void  insert(LawRepoLegalCategoryEntity legalCategoryEntity) {
        String uuid = UUID.randomUUID().toString().replaceAll("-", "");
        legalCategoryEntity.setUuid(uuid);
        legalCategoryEntity.setDelFlag("2");
        this.save(legalCategoryEntity);
    }

    @Override
    public void commonUpdateDelFlagBatch(String delFlag, Map<String, Object> mapIds){
        Map<String, Object> map = new HashMap<>(2);
        map.put("list", mapIds.get("ids"));
        map.put("delFlag", delFlag);
        baseMapper.commonUpdateDelFlagBatch(map);
    }



}
